# -*- coding:utf-8 -*-
# Author:Ami
# @Time    : 2018/11/18 9:21

import time

user, pw = "adc", "233"


def auth(auth_type):
    def outer_wrapper(func):
        def wrapper(*args, **kwargs):
            if auth_type == "local":
                username = input("Username:").strip()
                password = input("Password:").strip()
                if user == username and pw == password:
                    print("欢迎登陆")
                    res = func(*args, **kwargs)
                    # 万一有返回值
                    return res
                else:
                    exit("账户密码错误")
            if auth_type == "ldap":
                print("搞毛线ldap，不会……")
        return wrapper
    return outer_wrapper


def index():
    print("welcome to index page")


@auth(auth_type="local")  #auth() 表示outer_wrapper()运行了   注意括号
def home():
    print("welcome to home page")
    return "老子是home"


@auth(auth_type="ldap")
def bbs():
    print("welcome to bbs page")


index()

home()

bbs()
